public class MaxArea {
    // leetcode 盛最多水的容器
    // https://leetcode.cn/problems/container-with-most-water/description/?envType=study-plan-v2&envId=top-100-liked
    public int maxArea(int[] height) {
        int len = height.length;
        int left = 0, right = len-1, maxValue = 0;
        while (left < right) {
            maxValue = Math.max(maxValue, Math.min(height[left], height[right])*(right-left));
            if (height[left] < height[right]) left++;
            else {
                right--;
            }
        }
        return maxValue;
    }
}
